<template>
  <el-form :model="loginMsg" ref="ruleForm" label-width="100px" class="demo-ruleForm">

    <el-form-item label="账号" prop="id">
      <el-input type="text" v-model="loginMsg.accountId" autocomplete="off"></el-input>
    </el-form-item>

    <el-form-item label="密码" prop="pass">
      <el-input type="password" v-model="loginMsg.accountPwd" autocomplete="off"></el-input>
    </el-form-item>

    <el-form-item>
      <el-button type="primary" @click="submitForm()">提交</el-button>
    </el-form-item>

  </el-form>
</template>

<script>
import axios from "axios";

export default {
  name: "Login",
  data() {
    return {
      loginMsg: {}
    }
  },
  methods: {
    submitForm() {
      axios.post("http://localhost:8080/Account/login", this.loginMsg).then(resp => {
        if (resp.data.code === 2000){
          // 保存数九
          localStorage.setItem("userInfo", resp.data.data)
          // 弹出通知
          this.$notify({
            title: '成功',
            message: '登录成功',
            type: 'success'
          });
          // 成功后路由到index页码
          this.$router.push("/list")
        }else {
          this.$notify.error({
            title: '错误',
            message: '登录失败'
          });
        }
      })
    }
  }
}
</script>

<style scoped>

</style>